package org.xlx.xlx_oa.warehouse.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.xlx.xlx_oa.common.ResponseBean;
import org.xlx.xlx_oa.warehouse.api.WarehouseApi;
import org.xlx.xlx_oa.warehouse.domain.vo.WarehouseVo;
import org.xlx.xlx_oa.warehouse.service.WarehouseService;

@RestController
@RequestMapping("/v1/warehouse")
public class WarehouseController implements WarehouseApi {
    @Autowired
    private WarehouseService warehouseService;

    @PostMapping("/save")
    @Override
    public ResponseBean saveWarehouse(@RequestBody WarehouseVo warehouseVo) {
        return ResponseBean.successFactory(warehouseService.saveWarehouse(warehouseVo));
    }

    @DeleteMapping("/remove/{id}")
    @Override
    public ResponseBean removeWarehouse(@PathVariable(value = "id") Long id) {
        return ResponseBean.successFactory(warehouseService.removeWarehouse(id));
    }

    @PostMapping("/list")
    @Override
    public ResponseBean getList(@RequestBody WarehouseVo warehouseVo) {
        return ResponseBean.successFactory(warehouseService.getList(warehouseVo));
    }

    @PostMapping("/count")
    @Override
    public ResponseBean getCount(@RequestBody WarehouseVo warehouseVo) {
        return ResponseBean.successFactory(warehouseService.getCount(warehouseVo));
    }

    @PostMapping("/search")
    @Override
    public ResponseBean searchByTitle(@RequestParam(value = "title") String title) {
        return ResponseBean.successFactory(warehouseService.searchByTitle(title));
    }
}

